package com.lengxf.milo.node;

import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;

import java.util.Objects;

public class NodeIdBuilder {

    public static NodeId build(int namespaceIndex, String identifier) {
        NodeId nodeId = new NodeId(namespaceIndex, identifier);
        if (identifier.startsWith("ns=") && identifier.contains(";")) {
            nodeId = NodeId.parseOrNull(identifier);
        }
        if (Objects.isNull(nodeId)) {
            throw new NodeIdBuilderException(identifier);
        }
        return nodeId;
    }

    public static NodeId build(String identifier) {
        return build(3, identifier);
    }


}
